﻿package mortal.game.scene3D.fight
{
    import baseEngine.basic.*;
    import baseEngine.core.*;
    import baseEngine.modifiers.*;
    import flash.geom.*;
    import frEngine.effectEditTool.temple.*;
    import frEngine.render.layer.uiEffectLayer.*;
    import mortal.game.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.*;
    import mortal.game.scene3D.fight.dramaEffect.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.player.weapon.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.scene3D.player.entity.*;

    public class SkillEffectUtil extends Object
    {
        private static var _aryDramaEffect:Array = [];

        public function SkillEffectUtil()
        {
            return;
        }// end function

        public static function addPlayerEffectTest(param1:SpritePlayer, param2:String, param3:int, param4:Boolean = false, param5:Function = null, param6:int = 1, param7:Boolean = false) : EffectPlayer
        {
            var _loc_8:Pivot3D = null;
            if (!param1.bodyPlayer || !param1.parent || FightEffectUtil.isShieldSkill())
            {
                if (param5 != null)
                {
                    param5.call(null);
                }
                return null;
            }
            if (param7 && param1.bodyPlayer)
            {
                _loc_8 = param1.bodyPlayer;
            }
            else
            {
                _loc_8 = param1;
            }
            var _loc_9:* = UIEffectList.instance.getRenderListByUILayerID(param3);
            var _loc_10:* = EffectPlayerPool.instance.getEffectPlayer(param2, _loc_8, _loc_9, true, true, param4);
            if (param4)
            {
                _loc_10.game3DControler = Game.scene.gameControler;
            }
            else
            {
                _loc_10.game3DControler = null;
            }
            if (_loc_10.temple is TempleRole)
            {
                (_loc_10.temple as TempleRole).setRoleParams(param1.bodyPlayer, param5, null);
            }
            _loc_10.play(param6);
            return _loc_10;
        }// end function

        public static function addPlayerEffect(param1:SpritePlayer, param2:String, param3:Boolean = true, param4:Boolean = false, param5:Function = null, param6:int = 1, param7:Boolean = false, param8:Boolean = false, param9:Number = 0) : EffectPlayer
        {
            var _loc_10:Pivot3D = null;
            if (param1 == null)
            {
                return null;
            }
            if (!param1.bodyPlayer || param3 && !param1.parent || FightEffectUtil.isShieldSkill())
            {
                if (param5 != null)
                {
                    param5.call(null);
                }
                return null;
            }
            if (param7 && param1.bodyPlayer)
            {
                _loc_10 = param1.bodyPlayer;
            }
            else
            {
                _loc_10 = param1;
            }
            var _loc_11:* = EffectPlayerPool.instance.getEffectPlayer(param2, _loc_10, null, true, true, false);
            if (param4)
            {
                _loc_11.game3DControler = Game.scene.gameControler;
            }
            else
            {
                _loc_11.game3DControler = null;
            }
            if (param9 != 0)
            {
                _loc_11.direction = param9;
                _loc_11.useFightedPoint = true;
            }
            if (_loc_11.temple is TempleRole)
            {
                (_loc_11.temple as TempleRole).setRoleParams(param1.bodyPlayer, param5, null);
            }
            if (param8)
            {
                _loc_11.updateIndepentScale(true);
            }
            _loc_11.play(param6);
            return _loc_11;
        }// end function

        public static function addPointEffect(param1:Point, param2:String, param3:Boolean = false, param4:Number = 0, param5:Pivot3D = null) : void
        {
            if (FightEffectUtil.isShieldSkill())
            {
                return;
            }
            var _loc_6:* = EffectPlayerPool.instance.getEffectPlayer(param2, Game.scene.playerLayer, null, true, true, param3);
            _loc_6.x2d = param1.x;
            _loc_6.y2d = param1.y;
            _loc_6.direction = param4;
            _loc_6.play(PlayMode.ANIMATION_STOP_MODE);
            if (param3)
            {
                _loc_6.game3DControler = Game.scene.gameControler;
            }
            else
            {
                _loc_6.game3DControler = null;
            }
            return;
        }// end function

        public static function addTrackPlayer(param1:SpritePlayer, param2, param3:String, param4:Function) : EffectPlayer
        {
            var _loc_7:WeaponPlayer = null;
            if (FightEffectUtil.isShieldSkill())
            {
                if (param4 != null)
                {
                    param4.call(null);
                }
                return null;
            }
            if (param2 && param2 is SpritePlayer)
            {
                param2 = (param2 as SpritePlayer).bodyPlayer;
            }
            if (!param1 || !param2 || !param1.bodyPlayer)
            {
                param4.call(null);
                return null;
            }
            var _loc_5:* = param1 is RolePlayer;
            var _loc_6:* = EffectPlayerPool.instance.getEffectPlayer(param3, param1.bodyPlayer, null, true, true, _loc_5);
            if (!_loc_6)
            {
                param4.call(null);
                return null;
            }
            if (_loc_5)
            {
                _loc_6.game3DControler = Game.scene.gameControler;
            }
            else
            {
                _loc_6.game3DControler = null;
            }
            if (_loc_6.temple is TempleFight)
            {
                if (param1 is UserPlayer)
                {
                    _loc_7 = (param1 as UserPlayer).weaponPlayer;
                }
                (_loc_6.temple as TempleFight).setFightParams(param1.bodyPlayer, param2, _loc_7, true, param4, 1500);
                _loc_6.play(PlayMode.ANIMATION_LOOP_MODE);
                return _loc_6;
            }
            else
            {
                if (_loc_6.temple is TempleRole)
                {
                    (_loc_6.temple as TempleRole).setRoleParams(param1.bodyPlayer, param4, null);
                    _loc_6.play(PlayMode.ANIMATION_STOP_MODE);
                    return _loc_6;
                }
                param4.call();
            }
            return null;
        }// end function

        public static function addDramaEffect(param1:int, param2:Function = null) : DramaEffect
        {
            var _loc_3:* = DramaEffectConfig.instance.getDramaEffectInfo(param1);
            if (!_loc_3)
            {
                return null;
            }
            var _loc_4:* = new DramaEffect(_loc_3, param2);
            _aryDramaEffect.push(_loc_4);
            return _loc_4;
        }// end function

        public static function removeDramaEffect(param1:int) : void
        {
            var _loc_3:DramaEffect = null;
            var _loc_2:* = _aryDramaEffect.length - 1;
            while (_loc_2 >= 0)
            {
                
                _loc_3 = _aryDramaEffect[_loc_2] as DramaEffect;
                if (_loc_3 && _loc_3.dramaEffectInfo && _loc_3.dramaEffectInfo.code == param1)
                {
                    _loc_3.dispose();
                }
                _loc_2 = _loc_2 - 1;
            }
            return;
        }// end function

        public static function removeAllChildren() : void
        {
            var _loc_2:DramaEffect = null;
            var _loc_1:int = 0;
            while (_loc_1 < _aryDramaEffect.length)
            {
                
                _loc_2 = _aryDramaEffect[_loc_1] as DramaEffect;
                _loc_2.dispose();
                _loc_1++;
            }
            _aryDramaEffect = [];
            return;
        }// end function

    }
}
